﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using pdftron.PDF.Tools.Utilities;
using Windows.Storage;
using System.Diagnostics;

namespace CompleteReader.Utilities
{
    /// <summary>
    /// This class can be used to enable extra logging.
    /// </summary>
    public class AnalyticsHandler : AnalyticsHandlerBase
    {
        private static AnalyticsHandler _CURRENT;
        public static new AnalyticsHandler CURRENT
        {
            get
            {
                if (_CURRENT == null)
                {
                    _CURRENT = new AnalyticsHandler();
                }
                return _CURRENT;
            }
            set
            {
                _CURRENT = value;
            }
        }
        public string VersionName
        {
            get;
            set;
        }
        /// <summary>
        /// Search by username
        /// </summary>
        public string UserIdentifier
        {
            get;
            set;
        }
        public bool HandleWhileDebugging
        {
            get;
            set;
        }
        public void InitAndStartSession(Windows.UI.Xaml.Application app, string apiKey)
        {

        }

        /// <summary>
        /// Add global custom data
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public override void AddCrashExtraData(string key, string value)
        {

        }

        /// <summary>
        /// Clear global custom data
        /// </summary>
        public override void ClearCrashExtraData()
        {

        }

        /// <summary>
        /// Remove a custom extra data instance with key
        /// </summary>
        /// <param name="keyName"></param>
        /// <returns></returns>
        public override bool RemoveCrashExtraData(string keyName)
        {
            return false;
        }

        /// <summary>
        /// Log handled exceptions and send custom data Asynchronous
        /// </summary>
        /// <param name="ex"></param>
        public override void LogException(Exception ex)
        {

        }

        /// <summary>
        /// Log handled exceptions and send custom data Asynchronous
        /// </summary>
        /// <param name="ex"></param>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public override void LogException(Exception ex, string key, string value)
        {

        }

        /// <summary>
        /// Send an immediate exception with custom data Asynchronous
        /// </summary>
        /// <param name="ex">Exception</param>
        public override void SendException(Exception ex)
        {

        }

        /// <summary>
        /// Send an immediate exception with custom data Asynchronous
        /// </summary>
        /// <param name="ex">Exception</param>
        /// <param name="key">custom data key</param>
        /// <param name="value">custom data value</param>
        public override void SendException(Exception ex, string key, string value)
        {

        }

        /// <summary>
        /// Add breadcrumb to the global breadcrumb list
        /// </summary>
        /// <param name="evt">breadcrumb</param>
        public override void LeaveBreadcrumb(string evt)
        {

        }

        /// <summary>
        /// Clear global breadcrumb list
        /// </summary>
        public override void ClearBreadCrumbs()
        {

        }

        /// <summary>
        /// Set an action to be executed before the app crashes (save state)
        /// </summary>
        /// <param name="lastAction">An action that is to be executed just before an app crashes</param>
        public override void LastActionBeforeTerminate(System.Action lastAction)
        {
        }

        /// <summary>
        /// Log an event using the following method Asynchronous
        /// </summary>
        /// <param name="tag"></param>
        public override void LogEvent(string tag)
        {

        }

        /// <summary>
        /// Try to send an event immediately Asynchronous
        /// </summary>
        /// <param name="tag"></param>
        public override void SendEvent(string tag)
        {

        }

        /// <summary>
        /// Usage: int x = await GetTotalCrashesNum();
        /// </summary>
        /// <returns></returns>
        public Task<int> GetTotalCrashesNum()
        {
            return null;
        }

        /// <summary>
        /// Usage: long x = await GetLastCrashId();
        /// </summary>
        /// <returns></returns>
        public Task<long> GetLastCrashId()
        {
            return null;
        }

        /// <summary>
        /// AnalyticsHandler will log any asynchronous unawaited void or unobserved task exceptions
        /// </summary>
        public void RegisterAsyncHandlerContext()
        {

        }

        public override void Flush()
        {

        }

        /// <summary>
        /// Usage: bool x = await ClearTotalCrashesNum();
        /// </summary>
        /// <returns></returns>
        public override void ClearTotalCrashesNum()
        {

        }

        /// <summary>
        /// Close a session Asynchronous
        /// </summary>
        public override void CloseSession()
        {

        }

        public async Task<ulong> GetFileSizeAsync(IStorageFile file)
        {
            var properties = await file.GetBasicPropertiesAsync();

            return properties.Size;
        }
    }
}
